package com.lzl.controller;

import com.lzl.responese.ResponseResult;
import com.lzl.request.VerificationCodeDTO;
import com.lzl.service.VerificationCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class VerificationCodeController {

    @Autowired
    VerificationCodeService verificationCodeService;

    @GetMapping("/verification-code")
    public ResponseResult verificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO){
    //获取请求的手机号码
        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        System.out.println("获取请求的手机号码："+ passengerPhone);

        return verificationCodeService.generatorCode(passengerPhone);

    }

    @PostMapping("/verification-code-check")
    public ResponseResult verificationCodeCheck(@RequestBody VerificationCodeDTO verificationCodeDTO){
        //获取请求的手机号码
        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        String numberCode = verificationCodeDTO.getNumberCode();
        System.out.println("获取请求的手机号码："+ passengerPhone);

        return verificationCodeService.checkCode(passengerPhone,numberCode);
    }
}
